/***************************************************************
 * Name:      RadDllMain.cpp
 * Purpose:   Code for Application Frame
 * Author:     ()
 * Created:   2011-07-09
 * Copyright:  ()
 * License:
 **************************************************************/

#include "wx_pch.h"
#include "RadDllMain.h"
#include <wx/msgdlg.h>
#include "SecondFrame.h"
//(*InternalHeaders(RadDllFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(RadDllFrame)
const long RadDllFrame::ID_BUTTON1 = wxNewId();
const long RadDllFrame::ID_PANEL2 = wxNewId();
const long RadDllFrame::ID_STATICTEXT1 = wxNewId();
const long RadDllFrame::ID_PANEL1 = wxNewId();
const long RadDllFrame::idMenuQuit = wxNewId();
const long RadDllFrame::ID_MENUITEM1 = wxNewId();
const long RadDllFrame::idMenuAbout = wxNewId();
const long RadDllFrame::ID_STATUSBAR1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(RadDllFrame,wxFrame)
    //(*EventTable(RadDllFrame)
    //*)
END_EVENT_TABLE()

RadDllFrame::RadDllFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(RadDllFrame)
    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;
    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxMenu* Menu2;

    Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
    Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(136,192), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    Panel2 = new wxPanel(Panel1, ID_PANEL2, wxPoint(0,72), wxSize(176,84), wxTAB_TRAVERSAL, _T("ID_PANEL2"));
    Button1 = new wxButton(Panel2, ID_BUTTON1, _("Label"), wxPoint(56,48), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
    StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("对白高亮程序"), wxPoint(24,32), wxSize(72,16), 0, _T("ID_STATICTEXT1"));
    MenuBar1 = new wxMenuBar();
    Menu1 = new wxMenu();
    MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
    Menu1->Append(MenuItem1);
    MenuItem3 = new wxMenuItem(Menu1, ID_MENUITEM1, _("New Menu"), wxEmptyString, wxITEM_NORMAL);
    Menu1->Append(MenuItem3);
    MenuBar1->Append(Menu1, _("&File"));
    Menu2 = new wxMenu();
    MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
    Menu2->Append(MenuItem2);
    MenuBar1->Append(Menu2, _("Help"));
    SetMenuBar(MenuBar1);
    StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
    int __wxStatusBarWidths_1[1] = { -1 };
    int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
    StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
    StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
    SetStatusBar(StatusBar1);

    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&RadDllFrame::OnButton1Click);
    Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&RadDllFrame::OnPanel1Paint,0,this);
    Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&RadDllFrame::OnQuit);
    Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&RadDllFrame::OnAbout);
    //*)
}

RadDllFrame::~RadDllFrame()
{
    //(*Destroy(RadDllFrame)
    //*)
}

void RadDllFrame::OnQuit(wxCommandEvent& event)
{
    Close();
}

void RadDllFrame::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}

void RadDllFrame::OnButton1Click(wxCommandEvent& event)
{
    wxFrame *sf = new SecondFrame(this);
    sf->Show();
}

void RadDllFrame::OnPanel1Paint(wxPaintEvent& event)
{
}
